package com.sweet.mealon.face.daily.lock.ticket;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author: crazier.huang
 * @project: faceDaily
 * @date: 2021/4/29 星期四
 * @desc:
 */
@NoArgsConstructor
@Data
@AllArgsConstructor
public class TicketAdd {

    private int i ;
    private TicketSpinLock ticketSpinLock;

    public TicketAdd(TicketSpinLock ticketSpinLock) {
        this.ticketSpinLock = ticketSpinLock;
    }

    public void add(){
        i = i +1;
        System.out.println(String.format("i=%s",i));
    }

    public void addLock(){
        ticketSpinLock.lock();
        i = i +1;
        System.out.println(String.format("lock i=%s",i));
        ticketSpinLock.unlock();
    }

}
